<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <script src="https://cdn.jsdelivr.net/npm/vue@2/dist/vue.js"></script>
    <title>vue练习</title>
    
</head>
<body>
   <div id="app">
       <my-button :class="isColor?'red':'blue'" @change-color="isColor=!isColor">
           <template v-slot:header>
                <h1>hello</h1>
           </template>
       </my-button>
   </div>
</body>
<script>
    var myButton={
        props:['text'],
        template:`<div @click="$emit('change-color')"><slot name="header"></slot></div>`
    }
     var app=new Vue({
         el:"#app",
         components:{'my-button':myButton},
         data:{
            isColor:true
         },
         
     })
</script>
<style>
    .red{
        color:red
    }
    .blue{
        color:blue
    }
</style>
</html>